package com.grade.air.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.grade.air.domain.GzClassSchedule;
import com.grade.air.service.IGzClassScheduleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课程管理，每个班级的课程安排Controller
 * 
 * @author l
 * @date 2025-04-23
 */
@RestController
@RequestMapping("/air/schedule")
public class GzClassScheduleController extends BaseController
{
    @Autowired
    private IGzClassScheduleService gzClassScheduleService;

    /**
     * 查询课程管理，每个班级的课程安排列表
     */
    @PreAuthorize("@ss.hasPermi('air:schedule:list')")
    @GetMapping("/list")
    public TableDataInfo list(GzClassSchedule gzClassSchedule)
    {
        startPage();
        List<GzClassSchedule> list = gzClassScheduleService.selectGzClassScheduleList(gzClassSchedule);
        return getDataTable(list);
    }

    /**
     * 导出课程管理，每个班级的课程安排列表
     */
    @PreAuthorize("@ss.hasPermi('air:schedule:export')")
    @Log(title = "课程管理，每个班级的课程安排", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GzClassSchedule gzClassSchedule)
    {
        List<GzClassSchedule> list = gzClassScheduleService.selectGzClassScheduleList(gzClassSchedule);
        ExcelUtil<GzClassSchedule> util = new ExcelUtil<GzClassSchedule>(GzClassSchedule.class);
        util.exportExcel(response, list, "课程管理，每个班级的课程安排数据");
    }

    /**
     * 获取课程管理，每个班级的课程安排详细信息
     */
    @PreAuthorize("@ss.hasPermi('air:schedule:query')")
    @GetMapping(value = "/{scheduleId}")
    public AjaxResult getInfo(@PathVariable("scheduleId") Long scheduleId)
    {
        return success(gzClassScheduleService.selectGzClassScheduleByScheduleId(scheduleId));
    }

    /**
     * 新增课程管理，每个班级的课程安排
     */
    @PreAuthorize("@ss.hasPermi('air:schedule:add')")
    @Log(title = "课程管理，每个班级的课程安排", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GzClassSchedule gzClassSchedule)
    {
        return toAjax(gzClassScheduleService.insertGzClassSchedule(gzClassSchedule));
    }

    /**
     * 修改课程管理，每个班级的课程安排
     */
    @PreAuthorize("@ss.hasPermi('air:schedule:edit')")
    @Log(title = "课程管理，每个班级的课程安排", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GzClassSchedule gzClassSchedule)
    {
        return toAjax(gzClassScheduleService.updateGzClassSchedule(gzClassSchedule));
    }

    /**
     * 删除课程管理，每个班级的课程安排
     */
    @PreAuthorize("@ss.hasPermi('air:schedule:remove')")
    @Log(title = "课程管理，每个班级的课程安排", businessType = BusinessType.DELETE)
	@DeleteMapping("/{scheduleIds}")
    public AjaxResult remove(@PathVariable Long[] scheduleIds)
    {
        return toAjax(gzClassScheduleService.deleteGzClassScheduleByScheduleIds(scheduleIds));
    }
}
